<template>
  <div class="Son">
    <h1>我是孙组件</h1> 
    <button @click="isShow = true">点我打开</button>
    <teleport to='body'>
      <div class="mask" v-if="isShow">
         <div class="dialog">
          <h1>我是内容</h1>
          <h1>我是内容</h1>
          <h1>我是内容</h1>
          <button @click="isShow = false">点我关闭</button>
         </div>
      </div>
    </teleport>
  </div>
</template>
  
<script>
import {ref} from 'vue'
export default {
  name: "mySon",
  setup() {
    let isShow = ref(false);

    return{
        isShow
    }
  }
};
</script>
  
<style lang="css" scoped>
.dialog{
   height: 300px;
   width: 300px;
   background-color: green;
   text-align: center;
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%,-50%);
}
.mask{
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0,0,0,0.5);
}
.Son {
  background-color: orange;
  padding: 10px;
}
</style>